package com.shenmazg6.utils;

/**
 * @author 军哥
 * @version 1.0
 * @description: ResultResponse
 * @date 2022/12/19 14:01
 */

public class ResultResponse {

    private boolean success;
    private int code;
    private String message;
    private Object data;

    private ResultResponse() {
        data = null;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResultResponse SUCCESS() {
        ResultResponse response = new ResultResponse();

        response.setSuccess(true);
        response.setCode(200);
        response.setMessage("操作成功");
        response.setData(null);

        return response;
    }

    public static ResultResponse SUCCESS(Object data) {
        ResultResponse response = new ResultResponse();

        response.setSuccess(true);
        response.setCode(200);
        response.setMessage("操作成功");
        response.setData(data);

        return response;
    }

    public static ResultResponse FAILED(int code, String message) {
        ResultResponse response = new ResultResponse();

        response.setSuccess(false);
        response.setCode(code);
        response.setMessage(message);
        response.setData(null);

        return response;
    }

    public static ResultResponse FAILED(int code, String message, Object data) {
        ResultResponse response = new ResultResponse();

        response.setSuccess(false);
        response.setCode(code);
        response.setMessage(message);
        response.setData(data);

        return response;
    }
}
